﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FreshMeat.Xaml">

   <Style TargetType="local:ItemsGrid">
      <Setter Property="ItemsPanel">
         <Setter.Value>
            <ItemsPanelTemplate>
               <local:DynaGrid 
                  Background="#01000000"
                  Rows="{Binding Rows, RelativeSource={RelativeSource AncestorType=local:ItemsGrid}}" 
                  Columns="{Binding Columns, RelativeSource={RelativeSource AncestorType=local:ItemsGrid}}"
                  MinRowHeight="{Binding MinRowHeight, RelativeSource={RelativeSource AncestorType=local:ItemsGrid}}" 
                  MinColumnWidth="{Binding MinColumnWidth, RelativeSource={RelativeSource AncestorType=local:ItemsGrid}}"
                  RowHeight="{Binding RowHeight, RelativeSource={RelativeSource AncestorType=local:ItemsGrid}}" 
                  ColumnWidth="{Binding ColumnWidth, RelativeSource={RelativeSource AncestorType=local:ItemsGrid}}"/>
            </ItemsPanelTemplate>
         </Setter.Value>
      </Setter>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="local:ItemsGrid">
               <ItemsPresenter />
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="local:DragItem">
      <Setter Property="Background" Value="LightGray" />
      <Setter Property="Foreground" Value="#FFB30000" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="local:DragItem">
               <Grid>
                  <VisualStateManager.VisualStateGroups>
                     <VisualStateGroup x:Name="MoveStates">
                        <VisualStateGroup.Transitions>
                           <VisualTransition From="Blocked" GeneratedDuration="0:0:0.1" To="Allowed"/>
                        </VisualStateGroup.Transitions>
                        <VisualState x:Name="Allowed" />
                        <VisualState x:Name="Blocked" >
                           <Storyboard>
                              <DoubleAnimation Duration="0:0:0.1" To="0.3" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="blocker" />
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                     <VisualStateGroup x:Name="FeedbackStates">
                        <VisualStateGroup.Transitions>
                           <VisualTransition From="HasFeedback" GeneratedDuration="0:0:0.1" To="NoFeedback"/>
                        </VisualStateGroup.Transitions>
                        <VisualState x:Name="NoFeedback" />
                        <VisualState x:Name="HasFeedback" >
                           <Storyboard>
                              <DoubleAnimation Duration="0:0:0.1" To="0.7" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="feedback" />
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                  </VisualStateManager.VisualStateGroups>

                  <ContentPresenter x:Name="content" HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="1" />
                  <!--<Border x:Name="overlay" Background="LightGray" BorderBrush="Red" BorderThickness="2" CornerRadius="5" Padding="5" VerticalAlignment="Center" HorizontalAlignment="Center" Opacity="0" >
                  </Border>-->
                  <Grid Width="{TemplateBinding PopupWidth}" Height="{TemplateBinding PopupHeight}" VerticalAlignment="Center" HorizontalAlignment="Center">
                     <Grid x:Name="blocker" Opacity="0">
                        <Path Stretch="Fill" Stroke="Black" StrokeThickness="5" Data="M47.5,25 C47.5,37.426407 37.426407,47.5 25,47.5 12.573593,47.5 2.5,37.426407 2.5,25 2.5,12.573593 12.573593,2.5 25,2.5 37.426407,2.5 47.5,12.573593 47.5,25 z M9.1666667,9 L41,41" Margin="1,1,0,0" />
                        <Path Stretch="Fill" Stroke="{TemplateBinding Foreground}" StrokeThickness="5" Data="M47.5,25 C47.5,37.426407 37.426407,47.5 25,47.5 12.573593,47.5 2.5,37.426407 2.5,25 2.5,12.573593 12.573593,2.5 25,2.5 37.426407,2.5 47.5,12.573593 47.5,25 z M9.1666667,9 L41,41"  />
                     </Grid>
                     <Grid x:Name="feedback" Opacity="0" HorizontalAlignment="Center" VerticalAlignment="Center" >
                        <TextBlock Text="{TemplateBinding Feedback}" TextWrapping="Wrap" TextAlignment="Center" MaxWidth="100" FontSize="9" FontWeight="Bold" Foreground="Gray" Margin="1,1,0,0" />
                        <TextBlock Text="{TemplateBinding Feedback}" TextWrapping="Wrap" TextAlignment="Center" MaxWidth="100" FontSize="9" FontWeight="Bold" Foreground="Black" />
                     </Grid>
                  </Grid>
               </Grid>

            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="local:BusyIndicator">
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="local:BusyIndicator">
               <Grid >
                  <VisualStateManager.VisualStateGroups>
                     <VisualStateGroup x:Name="BusyStates">
                        <VisualStateGroup.Transitions>
                           <VisualTransition From="Busy" GeneratedDuration="0:0:0.1" To="NotBusy"/>
                        </VisualStateGroup.Transitions>
                        <VisualState x:Name="Busy">
                           <Storyboard>
                              <DoubleAnimation Duration="0:0:0.1" To="0.2" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="overlay" />
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="overlay">
                                 <DiscreteObjectKeyFrame KeyTime="0:0:0.0">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="overlay2">
                                 <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="NotBusy"/>
                     </VisualStateGroup>

                     <VisualStateGroup x:Name="BlockingStates">
                        <VisualState x:Name="Active">
                           <Storyboard>
                              <DoubleAnimation To="0.05" Duration="0:0:0.03" Storyboard.TargetName="overlay2" Storyboard.TargetProperty="Opacity" />
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Passive">
                           <Storyboard>
                              <DoubleAnimation To="0.0" Duration="0:0:0.03" Storyboard.TargetName="overlay2" Storyboard.TargetProperty="Opacity" />
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                  </VisualStateManager.VisualStateGroups>

                  <ContentPresenter />

                  <Border x:Name="overlay" Background="#ffffffff" Visibility="Collapsed" Opacity="0.0" />
                  <Border x:Name="overlay2" Background="#ffff0000" Visibility="Collapsed" Opacity="0.0" />
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="local:LayoutTransformer">
      <Setter Property="Foreground" Value="#FF000000"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="local:LayoutTransformer">
               <Grid x:Name="TransformRoot" Background="{TemplateBinding Background}">
                  <ContentPresenter
                            x:Name="Presenter"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"/>
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   
   <Style TargetType="local:ViewPicker">
      <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Visible" />
      <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="local:ViewPicker">
               <ContentPresenter  Content="{TemplateBinding SelectedItem}" ContentTemplate="{TemplateBinding ItemTemplate}" />
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="local:DropMenu">
      <!--<Setter Property="TabNavigation" Value="Once"/>-->
      <Setter Property="Height" Value="22" />
      <Setter Property="Padding" Value="0,0" />
      <Setter Property="Background" Value="#FF1F3B53"/>
      <Setter Property="BorderThickness" Value="1" />
      <Setter Property="BorderBrush">
         <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
               <GradientStop Color="#FFA3AEB9" Offset="0"/>
               <GradientStop Color="#FF8399A9" Offset="0.375"/>
               <GradientStop Color="#FF718597" Offset="0.375"/>
               <GradientStop Color="#FF617584" Offset="1"/>
            </LinearGradientBrush>
         </Setter.Value>
      </Setter>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="local:DropMenu">
               <Grid>
                  <ToggleButton x:Name="DropDownToggle" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Margin="0" Padding="{TemplateBinding Padding}" >
                     <Grid>
                        <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="Auto" />
                           <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <ContentPresenter Grid.Column="0" Content="{TemplateBinding Header}" />
                        <Path Grid.Column="1"  Data="F1 M 0,0L 11,0L 5,6L 0,0 Z " HorizontalAlignment="Center" VerticalAlignment="Center" Height="4" Stretch="Uniform" Width="8" Margin="3,0" >
                           <Path.Fill>
                              <SolidColorBrush Color="#FF333333"/>
                           </Path.Fill>
                        </Path>
                     </Grid>
                  </ToggleButton>

                  <Popup x:Name="Popup" >
                     <Grid Margin="0,0,3,3">
                        <Border Background="#30000000" Margin="7,7,-2,-2" CornerRadius="3" />
                        <Border Background="#18000000" Margin="5,5,-3,-3" CornerRadius="3" />
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                           <Border.Background>
                              <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                 <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                 <GradientStop Color="#FFFEFEFE" Offset="1"/>
                              </LinearGradientBrush>
                           </Border.Background>
                           <ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" MaxHeight="{TemplateBinding MaxMenuHeight}" MaxWidth="{TemplateBinding MaxMenuWidth}" MinWidth ="{TemplateBinding MinMenuWidth}" Margin="0" >
                              <ItemsPresenter/>
                           </ScrollViewer>
                        </Border>
                     </Grid>
                  </Popup>
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="local:DropMenuItem">
      <Setter Property="Padding" Value="3"/>
      <Setter Property="HorizontalContentAlignment" Value="Left"/>
      <Setter Property="VerticalContentAlignment" Value="Top"/>
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="BorderThickness" Value="1"/>
      <!--<Setter Property="TabNavigation" Value="Local"/>-->
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="local:DropMenuItem">
               <Grid Background="{TemplateBinding Background}">
                  <VisualStateManager.VisualStateGroups>
                     <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="MouseOver">
                           <Storyboard>
                              <DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor"/>
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled">
                           <Storyboard>
                              <DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="contentPresenter"/>
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                     <VisualStateGroup x:Name="SelectionStates">
                        <VisualState x:Name="Unselected"/>
                        <VisualState x:Name="Selected">
                           <Storyboard>
                              <DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor2"/>
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                     <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Focused">
                           <Storyboard>
                              <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="FocusVisualElement">
                                 <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                       <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                 </DiscreteObjectKeyFrame>
                              </ObjectAnimationUsingKeyFrames>
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unfocused"/>
                     </VisualStateGroup>
                  </VisualStateManager.VisualStateGroups>
                  <Rectangle x:Name="fillColor" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
                  <Rectangle x:Name="fillColor2" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
                  <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" />
                  <Rectangle x:Name="FocusVisualElement" RadiusY="1" RadiusX="1" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed"/>
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

</ResourceDictionary>
